<template>
	<view>
		<view class="querylist">
			<view class="queryfir">
				<picker v-if="showHead" @change="changeStore" :range="storeList" :value="storeIndex" :range-key="'storeName'">
					<view class="form_right"> 
						<view>
							{{storeList[storeIndex] ? storeList[storeIndex].storeName : '点击选择'}}
						</view>
						<image :src="BASE_IMG_URL+'newxia.png'" class="bottomimg" mode="scaleToFill"></image>
					</view>
				</picker> 
			</view>
			<view class="queryfir" style="margin-left: 10px;"> 
				<picker  @change="changeRead" :range="readList" :range-key="'name'"  :value="readIndex">
					<view class="form_right">
						<view>{{readList[readIndex] ? readList[readIndex].name : '请选择'}}</view>
						<image :src="BASE_IMG_URL+'newxia.png'" class="bottomimg"  mode="scaleToFill"></image>
					</view>
				</picker>
			</view>
		</view>
		<view class="fllow_item" v-for="(item,index) in lists" :key="index">
			<view class="unread" v-if="item.is_read != 1"></view>
			<view class="item_content" @click.stop="appointClick(item.apid)">
				<view class="con_img">
					<image :src="BASE_IMG_URL+ 'headImg.png'" class="headerimg"  mode="scaleToFill"></image>
					<view class="main_first">
						<view class="main_title">
							<view class="f_l_yop">
								<view>{{item.member_name}}</view>
								<view>{{item.phone}}</view>
								<view>{{item.goods_name?item.goods_name:''}}</view>
							</view>
							<view class="f_l_bottom" style="margin-top: 30rpx;">
								<view class="main_type daofang">
									{{item.status_desc}}
								</view> 
							</view> 
						</view>
						<view class="fontColor main_time">{{item.follow_time}}</view>
					</view>
				</view>
				<view class="con_main" >
					<view class="main_second">
						<view>{{item.remarks?item.remarks:''}}</view>
					</view> 
					<view class="main_third fontColor" v-if="item.usetime != null">
						<view class="third_left" >
							<view class="iconfont icon-clock"></view> 
							<view class="lxs_time">预约时间：{{item.usetime}}</view>
						</view>
						<view class="third_right">
							<view class="iconfont icon-arrows_right"></view>
						</view>
					</view>
					
					<view class="customer">指定员工：<span style="color:rgb(3, 170, 150)">{{item.staff_name ? item.staff_name : '--'}}</span></view>
				</view>
			</view>
		</view>
		<view style="height: 200rpx;"></view>
		<u-empty v-if="lists.length == 0" text="暂无更多"></u-empty>
		
		<!-- 创建用户图标 -->
		<view class="icon_creat" @click="appointClick('')">
			<image :src="BASE_IMG_URL+'1.png'" mode="scaleToFill"></image>
		</view>
		
	</view>
</template>

<script>
	import { BASE_IMG_URL } from '@/util/api.js'
	import {
		netMapKey,
		getAppCtx,  
		netGetChainStoreList
	} from '@/api/login.js'
	import { netAppointList } from '@/api/kehu.js'
	import {followRecordPageJumps, customerPageJumps} from "../crm_page_jumps.js";
	export default {
		mixins:[followRecordPageJumps, customerPageJumps],
		data() {
			return {
				appCtx: {},
				storeIndex: 0,
				storeList: [],
				showHead: false,
				tableFrom: {
					dateLimit: 'lately7',
					storeid: '',
				},
				page:1,
				limit:10,
				totalPage:1,
				readList:[{id:'',name:'全部'},{id:0,name:'未审核'},{id:1,name:'已预约'},{id:2,name:'已完成'},{id:4,name:'已取消'}],
				readIndex:0,
				BASE_IMG_URL:BASE_IMG_URL,
				lists:[]
			}
		},
		onLoad() {
				var that = this; 
			this.lists = []
			this.page = 1
			
			this.appCtx = getAppCtx()
			that.getStoreList();
			
		},
		onReachBottom() {
			if(this.page >= this.totalPage){
				return
			}
			this.page ++
			this.getList()
		},
		methods: { 
			changeStore(e) {
				this.storeIndex = e.detail.value
				this.page = 1
				this.lists = []
				this.tableFrom.storeid = this.storeList[e.detail.value].storeId
				this.getList()
			},
			getStoreList() {
 
				netGetChainStoreList({
					type: 'all'
				}).then(res => {
					this.storeList = res.data
					if (this.storeList.length > 1 && this.appCtx.loginedUser.roleType == 10) {
						this.showHead = true
					}
					
					this.storeList.unshift({
						storeName: '选择',
						storeId: ''
					})
					this.getList()
				})
			
			},
			changeRead(e) {
				this.readIndex = e.detail.value
				this.page = 1
				this.lists = []
				this.getList()
			},
			getList() {
				var that = this; 
				let params = {
					storeid: that.tableFrom.storeid,
					page: this.page,
					limit: this.limit,
					status: this.readList[this.readIndex].id
				} 
				netAppointList(params).then(res=>{
					this.lists = this.lists.concat(res.data.list)
					this.totalPage = res.data.totalPage
				})
			}, 
		}
	}
</script>

<style lang="scss">
	.querylist{
		margin:40rpx 0 30rpx;
		padding:0 30rpx;
		display: flex;
		justify-content: flex-end;
		align-items: center;
		.queryfir{
			box-shadow: 2rpx 2rpx 50rpx rgba(0,0,0,0.1);
			background:#fff;
			border-radius: 8rpx;
		}
		.form_right{
			width:180rpx;
			height:50rpx;
			font-size:22rpx;
			color:#666;
			text-align: center;
			line-height: 48rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			.bottomimg{
				width:20rpx;
				height:33rpx;
				margin-left:15rpx;
			}
		}
	}
	.fllow_item {
		position: relative;
		.unread{
			width:10rpx;
			height:10rpx;
			border-radius: 50%;
			position: absolute;
			right:5rpx;
			top:5rpx;
			background:#F43F3B;
		}
		.item_data {
			margin: 30rpx 0;
	
			&::before {
				content: '';
				display: inline-block;
				margin: 0 15rpx 0 24rpx;
				width: 20rpx;
				height: 20rpx;
				border-radius: 10rpx;
				border: 2rpx solid #03aa96;
			}
		}
	
		.item_content {
			display: block;
			background-color: #fff;
			padding: 24rpx 24rpx; 
			border-radius: 10rpx;
			margin-bottom: 30rpx;
	
			.con_img {
				display: flex;
				.main_first {
					margin-bottom: 25rpx;
					padding-left: 25rpx;
					flex: 1;
					.main_time{
						line-height: 25px;
					}
					.main_title{
						display: flex;
						width: 100%;
						justify-content: space-between;
						.first_left {
							display: flex;
						
							:first-child {
								font-size: 32rpx;
								margin-right: 10rpx;
								margin-top: -3rpx;
							}
						
							:last-child {
								margin-top: 2rpx;
							}
						}
						.main_type{
							padding:5rpx 20rpx;
							border-radius: 10rpx;
							color:#fff;
						}
						.daofang{
							background:#03aa96;
						}
						.genjin{
							background:#ff7800;
						}
						.other{
							background:#1CBBB4;
						}
					}
					
				}
				image {
					width: 100rpx;
					height: 100rpx;
					border-radius: 50%;
				}
			}
	
			.con_main {
				flex: 1;
				.main_second{
					padding-bottom:20rpx;
				}
				
				.main_img{
					display: flex;
					justify-content: flex-start;
					align-items: center;
					flex-wrap: wrap;
					margin-top: 20rpx;
					.imgbox{
						padding: 10rpx;
						border-radius: 5rpx;
						border:1rpx solid #CCCCCC;
						width:160rpx;
						height:160rpx;
						margin-right:14rpx;
						margin-bottom:14rpx;
					}
				}
				.main_third {
					display: flex;
					justify-content: space-between;
					align-items: center;
					margin: 20rpx 0 10rpx;
	
					.third_left {
						display: flex;
						align-items: center;
						.icon-clock{
							font-size:32rpx;
						}
						.lxs_time{
							margin-left: 5px;
							font-size:26rpx;
						}
					}
					.third_right {
						display: flex;
						.right_num {
							display: flex;
							:last-child {
								margin-right: 20rpx;
							}
						}
	
						.icon-arrows_right {
							margin-top: -4rpx;
						}
					}
				}
	
				.main_fourth {
					padding-bottom: 10rpx;
				}
			}
		}
	}
	.fontColor {
		color: #999;
	}
	.customer{
		margin-top:15rpx;
	}
</style>
